home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 19 / Mac Magazin and MacEasy Magazine CD - Issue 19.iso / Online / HttpServerƒ / •Mac_Classes / TThread.h < prev   
Text File  |  1996-01-03  |  2KB  |  75 lines

  1. //    TThread.h - Macintosh Thread class object
  2. // 
  3. // Apple Macintosh Developer Technical Support
  4. // Written by:  Vinne Moscaritolo
  5. //
  6. //  Copyright (work in progress)  Apple Computer, Inc All rights reserved.
  7. //
  8. // You may incorporate this sample code into your applications without
  9. // restriction, though the sample code has been provided "AS IS" and the
  10. // responsibility for its operation is 100% yours.  However, what you are
  11. // not permitted to do is to redistribute the source as "DSC Sample Code"
  12. // after having made changes. If you're going to re-distribute the source,
  13. // we require that you make it clear in the source that the code was
  14. // descended from Apple Sample Code, but that you've made changes.
  15. // 
  16.  
  17. #ifndef _H_TTHREAD
  18. #define _H_TTHREAD
  19.  
  20. #include <Threads.h>        // Thread manager
  21. #include "TContext.h"
  22.  
  23. class TThread
  24. {
  25.  
  26. //     CONSTRUCTORS AND DESTRUCTORS
  27. public:
  28.                     TThread();
  29.     virtual         ~TThread();
  30.  
  31. // HIGH LEVEL FUNCTIONS
  32. public:
  33.     void    Start();                
  34.     void    Stop(void* theResult = nil);
  35.     void    Sleep();
  36.     void    WakeUp();
  37.  
  38. // CALLBACK METHODS
  39. protected:
  40.     virtual    void*    Run();
  41.     virtual    void     Done();
  42.  
  43. // THREAD MANAGER CALLBACKS
  44. private:
  45.     static pascal void*    DoEntry            (void *);
  46.     static pascal void    DoTermination     (ThreadID , void*);
  47.     static pascal void    DoSwapIn          (ThreadID, void*);
  48.     static pascal void    DoSwapOut        (ThreadID, void*);
  49.  
  50. // PRIVATE METHODS
  51. private:
  52.     void     Initialize();
  53.  
  54. // PRIVATE FIELDS
  55. private:
  56.     TContext            fContext;
  57.     ThreadID            fTID;    
  58.     void*                fResult;
  59.  
  60. // CLASS FUNCTIONS
  61. public:
  62.     static     void    Allocate(short numToCreate, long MinStack);
  63.     static    void    Yield();
  64.     
  65. // CLASS VARIABLES
  66. private:
  67.     static Boolean                fgInited;            // is the thread class initialised?
  68.     static ProcessSerialNumber    fgPSN;                // ptr to application's PSN
  69.     static ThreadTaskRef        fgThreadTaskRef;    // thread task ref
  70. };
  71.  
  72.  
  73.  
  74. #endif
  75.